<template>
  <div class="search-songs" v-if="singerSong">
    <div class="marks"></div>
    <p>最佳匹配</p>
    <!-- <div class="singer" v-for="item in singerSong.artist" :key="item.id">
      <img :src="item.coverImgUrl" />
      <div class="singer-song">
        <span>歌手:</span><span>{{ item.name }}</span>
      </div>
    </div> -->
    <div class="singer" v-for="item in singerSong.artist" :key="item.id">
      <img :src="item.img1v1Url" />
      <div class="singer-song">
        <span>歌手:</span><span>{{ item.name }}</span>
      </div>
    </div>
    <ul class="singer-list">
      <li v-for="item in singerListSong" :key="item.id" @click="$emit('singer-song',item)">
        <div class="left">
          <h5>
            {{ item.name }}
            <span v-for="(ali, index) in item.song ? item.song.alias : item.alia" :key="index">{{ ali.name }}</span>
          </h5>
          <p>
            <b
              ><span  v-for="singers in item.song ? item.song.alia : item.ar"
            :key="singers.id">{{ singers.name }}</span>
              </b
            >
            -
            <i>{{ item.song ? item.song.album.name : item.al.name }}</i>
          </p>
          <div class="icon">
            <span v-if="playsong && playsong.id == item.id"
              ><i class="iconfont icon-zanting1"></i
            ></span>
            <span v-else><i class="iconfont icon-play1"></i></span>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data: function () {
    return {
      singerSong: null,
      singerListSong: null,
    };
  },

  props: ["value","playsong"],
  created: function () {
    this.axios
      .get(
        "https://apis.netstart.cn/music/search/multimatch?keywords=" +
          this.value
      )
      .then((res) => {
        console.log(res);
        this.singerSong = res.data.result;
      });

    this.axios
      .get("https://apis.netstart.cn/music/cloudsearch?keywords=" + this.value)
      .then((res) => {
        this.singerListSong = res.data.result.songs;
        console.log(res.data.result.songs);
      });
  },
};
</script>

<style lang="less" scoped>
.search-songs {
  position: absolute;


  width: 100%;
  top: 34px;
  right: 0;
  background: white;
  .marks{
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    right: 0;
    background: whitesmoke;
    z-index: -1;
  }
  p {
    font-size: 10px;
    margin: 5px 10px;
  }
  .singer {
    height: 50px;
    display: flex;
    align-items: center;
    margin: 10px;
   
    img {
      width: 50px;
      height: 50px;
    }
    .singer-song {
      margin-left: 10px;
      word-break: break-all;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
      span{
        margin: 5px;
      }
    }
  }
  .singer-list {
    list-style: none;
    padding: 0;
    margin: 0 5px;
    li{
      
         .left {
    position: relative;
    flex: 1;
    height: 60px;
    margin-top: 5px;
    h5 {
      // font-weight: bold;
      display: -webkit-box;
      font-size: 16px;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 1;
      overflow: hidden;
      margin: 0;
      color: black;
      span {
        color: gray;
      }
    }
    p {
      margin: 0;
      font-size: 10px;
      color: #999;
      b {
        font-weight: normal;
       
        span {
          &::after {
            content: "/";
          }
          &:last-child {
            &::after {
              content: "";
            }
          }
        }
      }
    }
  }
   .icon {
      position: absolute;
      right: 0;
      top: 0;
      span{

        i{

          font-size: 24px;
        }
      }
   
  }
    }
  }
}
</style>